package com.fr.report.web.ui.impl.write;

import com.fr.base.ArrayUtils;
import com.fr.base.ColumnRow;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.js.JavaScriptImpl;
import com.fr.report.web.event.Listener;
import com.fr.report.web.ui.Button;
import com.fr.report.web.ui.WebContentUtils;
import com.fr.web.Repository;

public class AppendRowButton extends Button
{
  private ColumnRow fixCell = null;
  private int count = 1;

  public ColumnRow getFixCell()
  {
    return this.fixCell;
  }

  public void setFixCell(ColumnRow paramColumnRow)
  {
    this.fixCell = paramColumnRow;
  }

  public int getCount()
  {
    return this.count;
  }

  public void setCount(int paramInt)
  {
    this.count = paramInt;
  }

  public Listener[] createListeners(Repository paramRepository)
  {
    return ((Listener[])ArrayUtils.addAll(super.createListeners(paramRepository), new Listener[] { new Listener("click", new JavaScriptImpl(WebContentUtils.getContentPanel(paramRepository) + ".appendReportRow(this.options.location, this.options.reportIndex," + this.count + ")")) }));
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    String str1 = null;
    if (paramXMLableReader.isChildNode())
    {
      String str2 = paramXMLableReader.getTagName();
      if (str2.equals("FixCell"))
      {
        int i = Integer.parseInt(paramXMLableReader.getAttr("row"));
        int j = Integer.parseInt(paramXMLableReader.getAttr("col"));
        setFixCell(ColumnRow.valueOf(j, i));
      }
      else if (str2.equals("count"))
      {
        if ((str1 = paramXMLableReader.getElementValue()) != null)
          setCount(Integer.parseInt(str1));
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (this.fixCell != null)
      paramXMLPrintWriter.startTAG("FixCell").attr("row", this.fixCell.row).attr("col", this.fixCell.column).end();
    if (this.count != 1)
      paramXMLPrintWriter.startTAG("count").textNode(String.valueOf(this.count)).end();
  }

  public boolean equals(Object paramObject)
  {
    if ((paramObject == null) || (!(paramObject instanceof AppendRowButton)))
      return false;
    AppendRowButton localAppendRowButton = (AppendRowButton)paramObject;
    return ((super.equals(paramObject)) && (ComparatorUtils.equals(getFixCell(), localAppendRowButton.getFixCell())) && (getCount() == localAppendRowButton.getCount()));
  }
}